import {
	mapMutations
} from 'vuex'
export default {
	...mapMutations([
		'upUserInfo'
	]),
	getPageData() {
		let that = this
		that.$httpRequest.request({
			that,
			url: 'setting/getUserAgreement',
			params: {},
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					that.netData = res.data.value
					console.log(res.data.value)
				} else {
					that.$toast.alert({
						content: res.message,
						callback: result => {
							if (result.confirm) {
								uni.navigateBack({
									delta: 1
								})
							}
						}
					})
				}
			}
		})
	},
	handlerNav(type) {
		let that = this
		switch (type) {
			case 1:
				// 联系我们
				uni.navigateTo({
					url: '/pages/my/contact'
				})
				break
			case 2:
				//使用协议
				uni.navigateTo({
					url: '/pages/publics/userAgreement'
				})
				break
			case 3:
				//意见反馈
				uni.navigateTo({
					url: '/pages/my/feedback'
				})
				break
			case 4:
				//退出登录
				// uni.removeStorageSync('token');
				// this.upUserInfo([])
				// uni.navigateTo({
				// 	url: '/pages/publics/login'
				// })
				this.$toast.confirm({
					content: '退出登录？',
					confirmText: '确认',
					callback: result => {
						if (result) {
							that.logOut()
						}
					}
				})
				break
			default:
				break
		}
	},
	logOut() {
		let that = this
		that.$httpRequest.get({
			that,
			url: 'wechat/logout',
			params: {},
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					that.$toast.alert({
						content: res.message,
						callback: result => {
							if (result.confirm) {
								uni.removeStorageSync('token');
								that.upUserInfo([])
								uni.navigateTo({
									url: '/pages/publics/login'
								})
							}
						}
					})
				} else {
					that.$toast.alert({
						content: res.message,
						callback: result => {
							if (result.confirm) {
								// uni.navigateBack({
								// 	delta: 1
								// })
							}
						}
					})
				}
			}
		})
	},
	cellme() {
		uni.navigateTo({
			url: '/pages/my/identification'
		})
	}
}